
<template>
  <el-form >
    <el-form-item :label-width="formLabelWidth" label="审核结果:" >
      <el-select    v-model="Form.audResultFlag.value" placeholder="审核结果">
        <el-option  label="请选择" value="-1"></el-option>
        <el-option  label="不同意驳回" value="0"></el-option>
        <el-option  label="同意并停开" value="1"></el-option>
      </el-select>
    </el-form-item>

  <el-form-item :label-width="formLabelWidth" label="退单原因类型:" >
      <el-select    v-model="Form.wrongType.value" placeholder="退单原因类型:">
        <el-option  label="后端资源不具备，资源原因停开" value="20190904"></el-option>
      </el-select>
    </el-form-item>

  
   <el-form-item :label-width="formLabelWidth" label="退单原因描述:">
      <el-input  type="textarea" v-model="Form.audComment.value" placeholder="退单原因描述"></el-input>
    </el-form-item>


    <el-form-item class="btnDir">
      <el-button @click="onSubmit">执 行</el-button>
      <el-button @click="onCancel">取 消</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import requestUtil from '@/utils/requestEnc';
import CustOrderService from "@/api/order/CustOrderService";
import { mapState } from "vuex";
export default {
 components: {
	
  },
  computed: {
		...mapState("orders", ["orderItemList"]),
		...mapState("user", ["user"]),
	},
  async mounted(){

    if(this.CTOInfo.length > 0){
      var orderItemIds="";
      var orderItemSeqs="";
      
      for(var i=0;i<this.CTOInfo.length;i++){
         if(i==0){
           orderItemIds += this.CTOInfo[i].orderItemId;
           orderItemSeqs += this.CTOInfo[i].orderItemSeq;
         }else{
            orderItemIds += ","+this.CTOInfo[i].orderItemId;
            orderItemSeqs += ","+this.CTOInfo[i].orderItemSeq;
         }
      }
      this.orderItemIds = orderItemIds;
      this.orderItemSeqs = orderItemSeqs;

      var scopeInfos=[]
      scopeInfos.push({scope:"orderTasks"});
      var custSoNumber = this.CTOInfo[0].custSoNumber;
      var batchNbr =  this.CTOInfo[0].batchNbr;
      var custId = this.CTOInfo[0].custId;
      
      this.orderItemIds = orderItemIds;
      const result=await CustOrderService.qryCustomerOrderDetail({custSoNumber,batchNbr,orderItemIds,custId,scopeInfos});
      var  orderTask = result.orderDetails[0]['orderTasks'][0];
      this.orderTask = orderTask;


    }else{
     
    }
  },
  watch:{

  },
  props:{
	  	ODKInfo: {
			type: Object,
			default: () => {
				return {};
			},
		},
		CTOInfo: {
			type: Array,
			default: () => {
				return [];
			},
		},
  },
  data() {
    return {
      orderTask:{},
      orderItemIds:"",
      orderItemSeqs:"",
      formLabelWidth:"120px",
     	Form:{
        audResultFlag:{
          options:[],
          value:""
        },
        wrongType:{
          value:""
        },
        audComment:{
          value:""
        }

    }
    }
  },
  methods: {
    isNull(val) {
      if (val == "NaN" || val == "null" || val == "undefined" || val == undefined) {
        return (val = "");
      }else {
        return val
      }
    },
    onCancel(){
      this.$emit('update:show',false)
    },
    async onSubmit(){
    
       var param = {
         "orderItemIds":this.orderItemIds,
         "custSoNumber":this.CTOInfo[0].custSoNumber,
         "audResultFlag":this.Form.audResultFlag.value,
         "audFlag":"",
         "staffId":this.user.staffId,
         "staffName":this.user.staffName,
         "isRight":"",
         "isWrong":"",
         "wrongType":"",
         "wrongReason":"",
         "audComment":this.user.staffName+":"+this.$util.dateFormat(new Date(),"yyyy-MM-dd")+":同意并停开:"+this.Form.audComment.value,
         "taskId":this.orderTask.orderTaskId,
         "custId":this.CTOInfo[0].custId
       }

      var result = await CustOrderService.dealAuditBackOrderOtn(param);
      
      	this.$confirm(result.meta.contractRoot.svcCont.resultMsg, "提示", {
								confirmButtonText: "确定",
								showCancelButton: false,
								type: "warn",
								center: true
								});
    }
  }
};
</script>

<style>
.el-form--inline .el-form-item {
  display: inline-flex;
  margin-right: 0.1rem;
  vertical-align: top;
  width: 42%;
}

.el-form-item__label {
  width: 94px;
}
.btnDir {
  margin-left: 36%;
  margin-top: 19px;
}
</style>
